package com.hsteach;

import com.hsteach.common.utils.StringUtils;
import com.hsteach.util.NetUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * 启动程序
 * 
 * @author fanxquer
 */

@EnableScheduling
@EnableFeignClients
@EnableDiscoveryClient
@EnableCaching
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@Slf4j
public class HsTeachApplication
{
    public static void main(String[] args)
    {
//        String hostName = getHostName();
//        log.info("hostName{}", hostName);
//        String ip = getIp();
//        log.info("ip{}", ip);
//        if ((StringUtils.isNotEmpty(hostName) && hostName.equals("localhost")) || (StringUtils.isNotEmpty(ip) && "127.0.0.1".equals(ip))) {
//            // 兼容nacos注册ip错误的问题，手动获取ip并设置到变量
//            List<String> ips = NetUtil.getLocalIpAddr(getNetworkInterface());
//            log.info("ips{}", ips);
//            System.setProperty("com.alibaba.nacos.client.naming.local.ip", ips.stream().findFirst().get());
//        }
        SpringApplication.run(HsTeachApplication.class, args);
        System.out.println("启动成功");
    }

}
